package org.wmq.positiontoshop.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Service;
import org.wmq.positiontoshop.common.LocalCache;

@Service
public class ShopListener {
    @Autowired
    private LocalCache localCache;

    @KafkaListener(topics = {"shop.update","shop.delete"}, groupId = "shop-group")
    public void handleShopUpdateAndDelete(String key, Acknowledgment ack) {
        this.localCache.remove(key);
        ack.acknowledge();
    }
}
